//
//  SLUpDataWatercraftView.m
//  StarLight
//
//  Created by Apple on 16/8/20.
//  Copyright © 2016年 Duke.Wu. All rights reserved.
//


// 说明: 船东版点击tabBar中间按钮弹框的View

#import "SLUpDataWatercraftView.h"
#import "SLSelectUpdateViewCell.h"
#import "SLUpdateWatercraftViewController.h"
#import "SLAddBoatViewController.h"
#import "SLAddGoodsViewController.h"


@interface SLUpDataWatercraftView ()<UITableViewDelegate, UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UIView *inputView;

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation SLUpDataWatercraftView


static NSString * const selectID = @"SLSelectUpdateViewCell";

- (instancetype)initWithModelView
{
    self = [[NSBundle mainBundle] loadNibNamed:@"SLUpDataWatercraftView" owner:nil options:nil].firstObject;
    
    self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];

    return self;
}


- (void)awakeFromNib
{
    self.inputView.layer.masksToBounds = YES;
    
    self.inputView.layer.cornerRadius = 5.0;
    
    self.tableView.delegate = self;
    
    self.tableView.dataSource = self;
    
    // 取消分割线
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    // 取消tableView的滚动
    self.tableView.scrollEnabled = NO;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"SLSelectUpdateViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:selectID];
    
    
}


#pragma mark -- 点击按钮调用的方法

// 点击添加按钮调用的方法
- (IBAction)appendBtn {
    
    SLAddBoatViewController *addBoatView = [[SLAddBoatViewController alloc]init];
    
    self.hidden = YES;
    
    addBoatView.hidesBottomBarWhenPushed = YES;
    
    [(UINavigationController *)self.parentController pushViewController:addBoatView animated:YES];
}


// 点击取消按钮调用的方法
- (IBAction)cancelBtn {
    
//    [self removeFromSuperview];
    self.hidden = YES;
}


#pragma mark -- <UITableViewDataSource>

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    SLSelectUpdateViewCell *cell = [tableView dequeueReusableCellWithIdentifier:selectID];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [cell.titleLabel setText:[NSString stringWithFormat:@"海牛4821"]];
    
    return cell;
}

#pragma mark -- <UITableViewDelegate>

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    SLUpdateWatercraftViewController *watercraftVc = [[SLUpdateWatercraftViewController alloc]init];
    
    self.hidden = YES;
    
    watercraftVc.hidesBottomBarWhenPushed = YES;
    
    [(UINavigationController *)self.parentController pushViewController:watercraftVc animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}

@end
